import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layouts/Layout.vue'
import Login from '../views/Login.vue'

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/',
    redirect: '/login', // 这里将根路径重定向到 /login
  },
  {
    path: '/event',
    component: Layout,
    children: [
      {
        path: '',
        name: 'Event',
        component: () => import('../views/events/EventList.vue')
      },
      {
        path: 'registration',
        name: 'Registration',
        component: () => import('../views/registrations/RegistrationList.vue')
      },
      {
        path: 'result',
        name: 'Result',
        component: () => import('../views/results/ResultList.vue')
      },
      {
        path: 'user',
        name: 'User',
        component: () => import('../views/users/UserList.vue')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router